package org.spolo.android.topic;

import org.spolo.android.nodetree.Stage;
import org.spolo.android.ui.UICanvas;




/*
 *  author : wxd 
 *  AppTopic manager
 */
public class AppTopicManager {
	/*
	 *	PRESETATION_360 360展示   0
	 *	PRESETATION_LD	亮点		1
	 *		PRESETATION_LD_CHILD_1       亮点1
	 *		PRESETATION_LD_CHILD_2       亮点2
	 *	PRESETATION_XX	销售		2
	 *		PRESETATION_XX_CHILD_1
	 *		PRESETATION_XX_CHILD_2
	 */
	public static final int PRESETATION_360 = 0;
	public static final int PRESETATION_LD = 1;
	public static final int PRESETATION_XX = 2;
	public static final int PRESETTION_CK = 3;
	
	public static final int PRESETATION_360_CHILD_1 = 4;
	public static final int PRESETATION_360_CHILD_2 = 5;
	public static final int PRESETATION_360_CHILD_3 = 6;
	public static final int PRESETATION_360_CHILD_4 = 7;
	public static final int PRESETATION_360_CHILD_5 = 8;
	
	public static final int PRESETATION_LD_CHILD_1 = 9;
	public static final int PRESETATION_LD_CHILD_2 = 10;

	public static final int PRESETATION_XX_CHILD_1 = 11;
	public static final int PRESETATION_XX_CHILD_2 = 12;
	public static final int PRESETATION_XX_CHILD_3 = 13;
	
	public static final int PRESETTION_CK_CHILD_1 = 14;
	public static final int PRESETTION_CK_CHILD_2 = 15;
	public static final int PRESETTION_CK_CHILD_3 = 16;
	public static final int PRESETTION_CK_CHILD_4 = 17;
	
	protected BaseTopic topic[] = new BaseTopic[18];
	protected int currentTopic = -1;
	public Stage root = Stage.getInstance();
	
	private static AppTopicManager app = null;
	private AppTopicManager(){
		topic[0] = new ShowTopic();
		topic[1] = new FuncTopic();
		topic[2] = new SellTopic();
		topic[3] = new InfoTopic();
		
		topic[4] = new ShowTopic_child_1();
		topic[5] = new ShowTopic_child_2();
		topic[6] = new ShowTopic_child_3();
		topic[7] = new ShowTopic_child_4();
		topic[8] = new ShowTopic_child_5();
		
		topic[9] = new FuncTopic_child_1();
		topic[10] = new FuncTopic_child_2();

		topic[11] = new SellTopic_child_1();
		topic[12] = new SellTopic_child_2();
		topic[13] = new SellTopic_child_3();
		
		topic[14] = new InfoTopic_child_1();
		topic[15] = new InfoTopic_child_2();
		topic[16] = new InfoTopic_child_3();
		topic[17] = new InfoTopic_child_4();
	}
	static public AppTopicManager instance(){
		if(app == null){
			app = new AppTopicManager();
		}
		return app;	
	}
	
	private void ActiveTopic(int topic){
		if(currentTopic == -1){
			UICanvas uiRoot = UICanvas.getInstance();
			uiRoot.initFirstMenu();
			root.addChild(uiRoot);
		}else if(currentTopic >= 0){
			this.topic[currentTopic].Deactive();
		}
		this.topic[topic].Active();
		currentTopic = topic;
	}
	
	public void topicChanged(int topic){
		if(topic != currentTopic){
			ActiveTopic(topic);
		}
		
	}
	
	public BaseTopic getTopic(int topic){
		return this.topic[topic];
	} 
	

}
	




